<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    class hyArray extends Array{
      get lastItem(){
        return this[this.length-1]
      }
      get firstItem(){
        return this[0]
      }
    }
    var arr = new hyArray(10,20,30)
    console.log(arr)
    console.log(arr.length)
    console.log(arr.lastItem)
    console.log(arr.firstItem)

    // 直接对Array进行扩展
    Array.prototype.lastItem = function(){
      return this[this.length-1]
    }
    var arr1 = new Array(10,23,34)
    console.log(arr1.lastItem())


    // 混入了解,JS是单继承
    // babel对es5和es6的转化P609 P610
  </script>
</body>
</html>